from masonite.routes import Route
from app.controllers.admin.AuthController import AuthController
from app.controllers.admin.HomeController import HomeController
from app.controllers.admin.AdminUserController import AdminUserController
from app.controllers.admin.AdminMenuController import AdminMenuController
from app.controllers.admin.AdminRoleController import AdminRoleController
from app.controllers.admin.AdminPermissionController import AdminPermissionController
from app.controllers.admin.AdminRolePermissionController import AdminRolePermissionController
from app.controllers.admin.AdminConfigController import AdminConfigController
from app.controllers.admin.AdminActionLogController import AdminActionLogController
from app.controllers.admin.AdminUserController import AdminUserController
from app.controllers.admin.AdminBindRoleController import AdminBindRoleController
from app.controllers.admin.AdminUserLoginLogController import AdminUserLoginLogController

# Route.get('/welcome', 'WelcomeController@show')
# Route.post('/welcome', 'WelcomeController@show')
# Route.put('/welcome', 'WelcomeController@show')
# Route.patch('/welcome', 'WelcomeController@show')
# Route.delete('/welcome', 'WelcomeController@show')
# Route.options('/welcome', 'WelcomeController@show')
# Route.view('/url', 'view.name', {'key': 'value'})
# Route.resource('/users', 'UsersController')
# Route.api('/users', 'UsersApiController')


ROUTES = [
    # Route.get("/", "WelcomeController@show"),

    Route.get("admin/user/login", AuthController.loginPage),  # 管理员后台-登录页面
    Route.post("admin/user/login", AuthController.login),  # 管理员登录

    # 管理员后台-首页
    Route.get('/', HomeController.index).middleware('admin_user_token'),
    Route.get('admin', HomeController.index).middleware('admin_user_token'),
    Route.get('admin/index', HomeController.index).middleware('admin_user_token'),

    # 管理员-登出
    Route.get('admin/user/logout', AuthController.logout).middleware('admin_user_token'),

    # 管理员-编辑信息
    Route.get('admin/user/edit2', AdminUserController.edit2).middleware('admin_user_token'),
    Route.put('admin/user/update2', AdminUserController.update2).middleware('admin_user_token'),

    # 管理员后台
    Route.group([
        # 菜单
        Route.get('menu/index', AdminMenuController.index),
        Route.get('menu/create', AdminMenuController.create),
        Route.get('menu/show', AdminMenuController.show),
        Route.get('menu/edit', AdminMenuController.edit),
        Route.post('menu/store', AdminMenuController.store),
        Route.put('menu/update', AdminMenuController.update),
        Route.delete('menu/destroy', AdminMenuController.destroy),

        # 角色
        Route.get('role/index', AdminRoleController.index),
        Route.get('role/show', AdminRoleController.show),
        Route.get('role/create', AdminRoleController.create),
        Route.get('role/edit', AdminRoleController.edit),
        Route.post('role/store', AdminRoleController.store),
        Route.put('role/update', AdminRoleController.update),
        Route.delete('role/destroy', AdminRoleController.destroy),

        # 访问权限
        Route.get('permission/index', AdminPermissionController.index),
        Route.get('permission/show', AdminPermissionController.show),
        Route.get('permission/create', AdminPermissionController.create),
        Route.get('permission/edit', AdminPermissionController.edit),
        Route.post('permission/store', AdminPermissionController.store),
        Route.put('permission/update', AdminPermissionController.update),
        Route.delete('permission/destroy', AdminPermissionController.destroy),

        # 角色权限
        Route.get('role-permission/index', AdminRolePermissionController.index),
        Route.get('role-permission/show', AdminRolePermissionController.show),
        Route.post('role-permission/store', AdminRolePermissionController.store),

        # 系统参数
        Route.get('config/index', AdminConfigController.index),
        Route.get('config/edit', AdminConfigController.edit),
        Route.put('config/update', AdminConfigController.update),

        # 操作日志
        Route.get('action-log/index', AdminActionLogController.index),
        Route.get('action-log/show', AdminActionLogController.show),

        # 管理员
        Route.get('user/index', AdminUserController.index),
        Route.get('user/show', AdminUserController.show),
        Route.get('user/create', AdminUserController.create),
        Route.get('user/edit', AdminUserController.edit),
        Route.post('user/store', AdminUserController.store),
        Route.put('user/update', AdminUserController.update),
        Route.delete('user/destroy', AdminUserController.destroy),

        # 管理员-绑定权限
        Route.get('bind-role/create', AdminBindRoleController.create),
        Route.post('bind-role/store', AdminBindRoleController.store),

        # 管理员-登录日志
        Route.get('user-login-log/index', AdminUserLoginLogController.index),
        Route.get('user-login-log/show', AdminUserLoginLogController.show),
    ],
        prefix      = 'admin',
        middleware  = ['admin_user_token'],
        # name        = '',
        # domain      = ''
    ),
]
